# TS平台 学生详情
import unittest
from time import sleep

from Common.base_test import BaseTestClass
from PageObjects.login.login_page import LoginPage
from PageObjects.TS.english_students_page import TsEnglishStudentPage
from TestDatas.login_datas import ts_user_data
from TestDatas.CommDatas import web_login_url
from TestDatas.TsDatas.ts_mystudents_datas import *
from Common.BeautifulReport import BeautifulReport
from Common.dir_config import *


class TsStudentDetail(BaseTestClass):
    """TS平台我的学员详情"""
    def test_0_1_go_to_ar_question_bank_management(self):
        """OA登录并跳转AR"""
        self.driver.get(web_login_url)
        self.lp = LoginPage(self.driver)
        # 步骤：登录页面-登录操作
        self.lp.login(ts_user_data["user"], ts_user_data["pwd"])
        sleep(3)
        self.assertTrue(self.lp.assert_welcome())
        self.lp.go_ts()
        self.lp.switch_window("教学服务平台")
        sleep(10)

    def test_0_2_eng_stu_lst(self):
        """英文课程学员-列表"""
        self.tp = TsEnglishStudentPage(self.driver)
        self.tp.go_my_stu_nav()  # 点击导航栏我的学员-英文课程学员
        self.tp.eng_stu_lst()  # 搜索
        stu_lst_text = self.tp.get_eng_lst_text()  # 获取学员列表数据
        self.assertIn(ts_row_link_loc_data, stu_lst_text, "列表数据不包含【{}】，断言失败".format(ts_row_link_loc_data))

    def test_0_3_stu_detail(self):
        """英文课程学员-学员详情"""
        self.tp = TsEnglishStudentPage(self.driver)
        # 开课中数据   为开课数据       已结束数据        订单数据
        having_data, not_class_data, finished_data, order_data = self.tp.eng_stu_detail()
        self.assertIn(ts_having_expect_data, having_data, "开课中数据未包含预期结果数据，请检查")
        self.assertIn(ts_not_class_expect_data, not_class_data, "未开课数据未包含预期结果数据，请检查")
        self.assertIn(ts_finished_expect_data, finished_data, "已结课数据未包含预期结果数据，请检查")
        self.assertIn(ts_order_expect_data, order_data, "订单数据未包含预期结果数据，请检查")
        self.tp.more_message()
        self.tp.more_order()


if __name__ == '__main__':
    # unittest.main()
    suite = unittest.TestSuite()
    suite.addTests(unittest.makeSuite(TsStudentDetail))
    result = BeautifulReport(suite)
    result.report(filename="TS英文课程学员测试报告", description='TS我的学员英文课程学员', log_path=htmlreport_dir)
